package com.wwh.furns.dao.impl;

import com.wwh.furns.dao.BasicDAO;
import com.wwh.furns.dao.OrderDAO;
import com.wwh.furns.entity.Order;

import java.util.List;

/**
 * @author Albert
 * @date 2024/7/31-19:33
 * @describe
 */
public class OrderDAOImpl extends BasicDAO<Order> implements OrderDAO {
    @Override
    public int saveOrder(Order order) {
        String sql = "INSERT INTO `order`(`id`, `create_time`, `price`, `status`, `member_id`) " +
                "VALUE(?, ?, ?, ?, ?)";
        return update(sql, order.getId(), order.getCreateTime(), order.getPrice(), order.getStatus(), order.getMemberId());
    }

    @Override
    public List<Order> readOrder(Integer memberId) {
        String sql = "select id, create_time as createTime, price, status, member_id as memberId from `order` where member_id = ?";
        return queryMulti(sql, Order.class, memberId);
    }
}
